Lightfield Camera

Background

Capturing multiple images over a plane orthogonal to the optical axis enables achieving complex effects using very simple operations like shifting and averaging.The goal of this project is to reproduce some of these effects using real lightfield data.

1. Depth Refocusing

Approach

First, I took the image at (8, 8) to be the center image. Then I found the displacement between each image in the image set and the center image. For each image, I would shift it by (c * dx, c * dy), where c is some constant and dx, dy are displacements in the x and y direction, respectively. After shifting the images, I took their average and returned the resulting image.

Center Image

center_img.jpg

Average Image

avg_img.jpg

Depth Refocusing on Different c-values

neg5.jpgneg2.jpgneg1.jpgnada.jpgpos1.jpgpos2.jpgpos5.jpg

2. Aperture Adjustment

Approach

The idea of this part is to refocus based on a subset of images, which are all within some radius of the center image. For example, if radius=2, the subset would be a 5x5 grind around the center image. To do this, I first created a 17x17 grid to assist with finding the nearest images. Then, I found the refocused image (with c=0.2 to focus on the center of the image) for each subset of images with integer radii in range [0, 9]. The results are shown below.

Apertures at Different Radii

r0.jpgr1.jpgr2.jpgr3.jpgr4.jpgr5.jpgr6.jpgr7.jpgr8.jpg

Summary

In this project, I learned that lightfields have very cool functions and complex effects, like adjusting parameters to change the focus of certain parts of an image.

Gradient Domain Fusion

Background

This project explores gradient-domain processing, a simple technique with a broad set of applications including blending, tone-mapping, and non-photorealistic rendering, specifically focusing on Poisson blending. The primary goal of this assignment is to seamlessly blend an object or texture from a source image into a target image.

2.1 Toy Problem

Approach

For this part, we recover the original image using the minimization of v equation, listed on the project spec. I wrote each objective by following the hints in "Implementation Details", then using scipy.sparse.linalg.lsqr to solve for v. The results are shown below.

Original vs Reconstructed Images

peng.jpg
Original Image
penggdf.jpg
Reconstructed Image
toy.jpg
Original Image
toygdf.jpg
Reconstructed Image

2.2 Poisson Blending

Approach

For this part, I used a similar approach as the toy problem, but tweaking the parameters and calculations a little (e.g. only calculating the part of image overlapping with the mask and expanding A and b four-fold because of the calculations on the 4-neighborhood). Also like the last part, I followed the "Implementation Details" of part 2.1 to find the objectives. This time, I would subtract the pixel from some coordinate (x,y) from its 4-neighborhood. I once again used scipy.sparse.linalg.lsqr to solve for v. Then, I transfered the pixels from v to my output image. The results are shown below. (Look! Oraple from project 2 is back!)

Images, Masks, and Blending

hikers.jpg
Background Image
peng.jpg
Object Image
pengmask.jpg
Mask
pengblend.jpg
Blended Image
hojicha.jpg
Background Image
anna.jpg
Object Image
annamask.jpg
Mask
anahojicha.jpg
Blended Image
apple.jpg
Background Image
orange.jpg
Object Image
vert_mask.jpg
Mask
oraple.jpg
Blended Image

Bells and Whistles: Mixed Gradients

Approach

My implementation for mixed gradient blending was almost identical to my implementation of Poisson blending, except I set d_ij = t_i - t_j if t_i - t_j > s_i - s_j, where s is the source image and t is the target image.

Mixed Gradient vs Poisson Blending

mixedpeng.jpg
Mixed Gradient Blend
pengblend.jpg
Poisson Blend
mixedanna.jpg
Mixed Gradient Blend
anahojicha.jpg
Poisson Blend
mixedoraple.jpg
Mixed Gradient Blend
oraple.jpg
Poisson Blend